import httpInstance from '@/utils/http'

// 获取动态详情
export const getDynamicDetail = (dynamicId) => {
  return httpInstance({
    url: `/api/dynamic/getDynamicById/${dynamicId}`,
    method: 'get',
  })
}

export const getAllDynamic = (params) => {
  return httpInstance({
    url: '/api/dynamic/getAllDynamic',
    method: 'get',
    params: params,
  })
}

// 创建动态
export const createDynamic = (dynamicData) => {
  return httpInstance({
    url: '/api/dynamic/createDynamic', // 后端创建动态的接口地址
    method: 'post',
    data: dynamicData, // 动态数据
  })
}

// 修改动态
export const updateDynamic = (dynamicId, dynamicData) => {
  return httpInstance({
    url: `/api/dynamic/updateDynamic/${dynamicId}`, // 使用反引号包裹
    method: 'put',
    data: dynamicData,
  })
}

// 删除文章
export const deleteDynamic = (dynamicId) => {
  return httpInstance({
    url: `/api/dynamic/deleteDynamic/${dynamicId}`, // 使用反引号包裹
    method: 'put',
  })
}

// 获取用户动态
export const getUserDynamic = (uid) => {
  return httpInstance({
    url: `/api/dynamic/getUserDynamic/${uid}`,
    method: 'get',
  })
}
